﻿<!--#include file="conn.asp"-->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>批量生成HTML</title>
    <style type="text/css">
        body
        {
            font-size: 9pt;
            line-height: 140%;
        }
    </style>
</head>
<body>
    <%
set rs=server.createobject("adodb.recordset")
set rsm=server.createobject("adodb.recordset")
id=request("id")
rs.open "select * from comics where id="&request("id"),conn,1,1
     if not rs.eof then
	 id=rs("id")
       comic_name=rs("mhmc")
       zzid=rs("zzid")
	   set rs2=server.createobject("adodb.recordset")
sql2="select * from zz where id ="&rs("zzid")&""
rs2.open sql2,conn,1,1
if not rs2.eof then
zzname=rs2("zzmc")
end if
rs2.close
	   comic_info=rs("mhjs")
	   comic_pic=rs("mhfm")
       comic_bm=rs("mhbm")
       comic_tc=rs("mhtc")
       comic_classid=rs("classid")
	   adddate=rs("adddate")
	    ywjbz=rs("zt")
	   datetime=year(rs("adddate"))&"-"&month(rs("adddate"))&"-"&day(rs("adddate"))
	 end if
     if ywjbz = true then
	 wjbz=wjbz& "<FONT color=green>已完结</FONT>"
	 else
	  wjbz=wjbz& "<FONT color=red>连载中</FONT>"
	  end if
	  zm=zm& "<A href=""/list/"&rs("zm")&"/"">字母索引 "&rs("zm")&" 漫画列表</A>"
   rs.close 
      


sql="select * from comics order by hits desc"
rs.open sql,conn,1,1
if rs.eof then
comic_new="·还没有添加"
else
do while not rs.eof
titley=left(rs("mhmc"),8)
hits=rs("hits")
h=h+1
comic_hits=comic_hits&"<li><span class=t"&h&">"&h&".</span><a href=""/comic/"&rs("id")&"/"" target=_blank title="&rs("mhmc")&">"&rs("mhmc")&"</a></li>"
if h>=10 then exit do
rs.movenext
loop
h=0
end if
rs.close

sql="select * from comics order by hits_m desc"
rs.open sql,conn,1,1
if rs.eof then
comic_new="·还没有添加"
else
do while not rs.eof
titley=left(rs("mhmc"),8)
hits=rs("hits")
h=h+1
comic_hits2=comic_hits2&"<li><span class=t"&h&">"&h&".</span><a href=""/comic/"&rs("id")&"/"" target=_blank title="&rs("mhmc")&">"&rs("mhmc")&"</a></li>"

if h>=10 then exit do
rs.movenext
loop
h=0
end if
rs.close


sql="select * from zj where cid in("&id&") order by id desc"
rs.open sql,conn,1,1
if rs.eof then
joindatetime="没有更新"
else
joindatetime=year(rs("adddate"))&"-"&month(rs("adddate"))&"-"&day(rs("adddate"))
end if

rs.close

'查询类似的漫画按点击量排序
similarList=""
sql="select a.id,a.mhmc,a.mhfm,a.zm,a.zt,b.zjid,c.zjmc from comics a join (select MAX(id) zjid,cid from zj group by cid) b on a.id=b.cid join zj c on b.zjid=c.id where a.id in (select id from (select top(10) id from ("
if trim(comic_tc)="" or isnull(comic_tc) then 
else
tcArray=Split(comic_tc," ")
for i=0 to  ubound(tcArray)
sql=sql&"select id from comics where mhtc like '%"&tcArray(i)&"%' union all "
next
end if
sql=sql&"select id from comics where mhmc like '%"&replace(comic_name,"'","''")&"%' union all "
sql=sql&"select id from comics where zzid="&zzid&" union all "
sql=sql&"select id from comics where classid="&comic_classid
sql=sql&") c where id<>"&id&" group by id order by newid()) b)"
rs.open sql,conn,1,1
if rs.eof then
else
 i=0
do while not rs.eof
zjid=rs("id")
zj_name=rs("zjmc")
i=i+1
if i>100000 then exit do
 similarList=similarList&"<li><p class='cover'><a class='pic' href='/comic/"&rs("id")&"'><img src='/cpic/"&rs("mhfm")&"' alt='"&rs("mhmc")&"' height='160' width='120'></a> <span>最近更新："&rs("zjmc")&"</span></p><a title='"&rs("mhmc")&"' href='/comic/"&rs("id")&"'>"&rs("mhmc")&"</a></li>"
		rs.movenext
		loop
		end if
rs.close


sql="select * from zj where cid in("&id&") order by id desc"
rs.open sql,conn,1,1
if rs.eof then
 zjlist=zjlist&"<li>暂无章节</li>"
else
 i=0
do while not rs.eof
zjid=rs("id")
zj_name=rs("zjmc")
i=i+1
if i>100000 then exit do
if DateDiff("d",rs("adddate"),now())<=7 then'七天之内为新
zjlist=zjlist&"<li><a href="""&zjid&"/"" target=""_blank"" class=""new"">"&zj_name&"<em></em></a></li>"
else
zjlist=zjlist&"<li><a href="""&zjid&"/"" target=""_blank"">"&zj_name&"</a></li>"
end if
 
		rs.movenext
		loop
		end if
		 set rs = nothing 
conn.close  

set conn=nothing
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'set fr=fso.opentextfile(server.mappath("temp/comic.htm"))
'pencat=fr.readall
'fr.close
pencat=ReadFromTextFile("temp/comic.htm","utf-8")

pencat=commonreplace(pencat)

pencat=replace(pencat,"[NEW]",comic_new)
pencat=replace(pencat,"[HITS]",comic_hits)
pencat=replace(pencat,"[COMIC_ID]",id)
pencat=replace(pencat,"[TITLE]",comic_name)
pencat=replace(pencat,"[TITLEBM]",comic_bm)
pencat=replace(pencat,"[ZZ]",zzname)
pencat=replace(pencat,"[ZZID]",zzid)
pencat=replace(pencat,"[ZJLIST]",zjlist)
pencat=replace(pencat,"[PH]",comic_hits)
pencat=replace(pencat,"[PH2]",comic_hits2)
pencat=replace(pencat,"[INFO]",comic_info)
pencat=replace(pencat,"[ZM]",zm)
pencat=replace(pencat,"[PIC]",comic_pic)
pencat=replace(pencat,"[ADD_DATA]",datetime)
pencat=replace(pencat,"[JOIN_DATE]",joindatetime)
pencat=replace(pencat,"[ZT]",wjbz)
pencat=replace(pencat,"[WEB_NAME]",web_name)
pencat=replace(pencat,"[WEB_URL]",web_url)
pencat=replace(pencat,"[WEB_BA]",miibeian)
pencat=replace(pencat,"[SimilarList]",similarList)
pencat=adreplace(pencat)

if fso.folderexists(server.mappath("../comic/"&id&"\"&foldername))=false then
Fso.Createfolder(server.mappath("../comic/"&id&"\"&foldername))
end if
'Set fout = fso.CreateTextFile(server.mappath("../comic/"&id&"/index.htm"))
'fout.Write pencat
'fout.close
WriteToTextFile "../comic/"&id&"/index.htm",pencat,"utf-8"

if request("type")="page" then%><font color="#FF0000">生成漫画页面完成</font><script type="text/javascript">
<!--
                                                                         setTimeout('window.close();', 500);
// -->
</script>
    <%end if%>
</body>
</html>
